package edu.hunau.cxb19.oop.class20;

import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.Set;

import org.junit.Test;

/**
 *
 * @author hb
 *
 *         2020-03-23 14:46:33
 */
public class SetTest {

	@Test
	public void addTest() {
		Set<String> set = new HashSet<String>();
		set.add("b");
		set.add("c");
		set.add("a");
		set.add("b");
		System.out.println(set.size());// 3
		System.out.println(set);// [a, b, c]

		Iterator<String> iterator = set.iterator();
		while (iterator.hasNext()) {
			String datas = iterator.next();
			System.out.println(datas);
		}

		for (String datas : set) {
			System.out.println(datas);
		}
	}
	
	@Test
	public void addLinkedHashSetTest() {
		Set<String> set = new LinkedHashSet<String>();
		set.add("b");
		set.add("c");
		set.add("a");
		set.add("b");
		System.out.println(set.size());// 3
		System.out.println(set);// [b, c, a]
 

	}
}
